<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>正则对象</title>
</head>
<body>
<script>

    //正则对象声明方式二
    let email = prompt("请输入您的邮箱")
    let reg = new RegExp("^\\w+@\\w+(\\.\\w+)+$")

    /*正则对象声明方式一*/
   // var reg = /^\w+@\w+(\.\w+)+$/g

    //email.match(reg)

    var b = reg.test(email);
    // console.log("b="+b)
    // console.log(typeof b)
    if(b){
        console.log("邮箱格式正确")
    }else{
        console.log("邮箱格式不正确")
    }

</script>
</body>
</html>